namespace Gouzao {
    interface MyClassConstructor {
        new(num1: number, uname: string): {
            sayhi(): string;
        };
    }

    class MyClass {
        constructor(public num1: number, public uname: string) {
        }

        sayhi(): string {
            return 'sda';
        }
    }


    function createInstance(ctor: MyClassConstructor, num1: number, uname: string) {
        return new ctor(num1, uname);
    }

    const instance = createInstance(MyClass, 1, 'example');
    console.log(instance.sayhi()); // 输出: sda


    // 用来约束构造函数中的参数和实例方法
    type yueConstruct = new (a: string, b: string) => {
        hasZks(a: string): string
    }

    class zks {
        a: string
        b: string

        constructor(a: string, b: string) {
            this.a = a
            this.b = b
        }

        hasZks(a: string) {
            return a
        }
    }

    function createIn(ctor: yueConstruct) {
        return new ctor('1', '2')
    }

    createIn(zks)
}